import {
  Body,
  Controller,
  Get,
  HttpCode,
  HttpStatus,
  Post,
} from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { LetterService } from './letter.service';
import {
  UpdateParam,
  AddParam,
  UpdateCurrentParam,
  DtlCurrentParam,
} from './letter.interface';

@ApiTags('信件管理')
@Controller('letter')
export class LetterController {
  constructor(private readonly service: LetterService) {}

  // 获取信件列表
  @Get('query')
  @ApiOperation({ summary: '获取信件列表' })
  queryLetters() {
    return this.service.queryLettersService();
  }

  // 获取一封信页面显示的列表
  @Get('queryCurrent')
  @ApiOperation({ summary: '获取一封信页面显示的列表' })
  queryCurrentLetter() {
    return this.service.queryCurrentLetterService();
  }

  // 新增
  @Post('add')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '新增' })
  add(@Body() param: AddParam) {
    return this.service.addService(param);
  }

  // 更新信件内容
  @Post('update')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '更新信件内容' })
  update(@Body() param: UpdateParam) {
    return this.service.updateService(param);
  }

  // 将信件设置为一封信的内容
  @Post('updateCurrent')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '将信件设置为一封信的内容' })
  updateCurrent(@Body() param: UpdateCurrentParam) {
    return this.service.updateCurrentService(param);
  }

  // 删除
  @Post('delete')
  @HttpCode(HttpStatus.OK)
  @ApiOperation({ summary: '删除' })
  delete(@Body() param: DtlCurrentParam) {
    return this.service.deleteService(param);
  }
}
